package _9练习类;

public class StringExercise {
	public static void main(String[] args) {
		//1.
		op();
		
		//2.
		del();
		
		//3.
		replace();
		
		//4.
		file();
		
	}

	
	
	//4.
	private static void file() {
		
		String filePath = "e:/abc/bbb/1.png";
		System.out.println(filePath.lastIndexOf("/"));
		System.out.println(filePath.substring(11));
		System.out.println(filePath.substring(0, 11));
		System.out.println(filePath.substring(12));
		
		if(filePath.substring(12).equals(".png"))
			System.out.println("是png图片");
		else
			System.out.println("不是png图片");
		
	}



	//3.
	private static void replace() {
		
		StringBuilder s3=new StringBuilder("猫抓老鼠，老鼠怕猫");
		s3.replace(0, 1, "老鼠");
		s3.replace(3, 5, "猫");
		s3.replace(5, 7, "猫");
		s3.replace(7, 9, "老鼠");
		System.out.println(s3);
		
	}


	//2.
	private static void del() {
		
		String s2 = "Andorid IOS Windows Linux";
		
		System.out.println(s2.replace("IOS", ""));
		
	}
	
	
	//1.
	private static void op() {
		
		String s1 = "When a man love a woama,when i you man Xman";
		System.out.println(s1.indexOf("man"));
		System.out.println(s1.indexOf("man", 15));
		System.out.println(s1.lastIndexOf("man"));
		int count=0;
		for(int i=0;i<s1.length()-2;i++)
		{
			if(s1.charAt(i)=='m')
			{
				if(s1.charAt(i+1)=='a')
				{
					if(s1.charAt(i+2)=='n')
						count++;
				}
			}
		}
		System.out.println(count);
		
		System.out.println(s1.toUpperCase());
				
	}
	
}